package com.todo.sight.application.convert;

import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.todo.common.common.enums.BusinessSceneEnum;
import com.todo.common.common.enums.CityTypeEnum;
import com.todo.common.common.enums.EnableTypeEnum;
import com.todo.common.common.enums.SourceEnum;
import com.todo.common.utils.TodoCommonUtils;
import com.todo.sight.application.entity.bo.*;
import com.todo.sight.application.entity.condition.CityInfoConditionBO;
import com.todo.sight.application.entity.condition.PoiConditionBO;
import com.todo.sight.application.entity.condition.SightQueryConditionBO;
import com.todo.sight.common.enums.PoiBusinessTypeEnum;
import com.todo.sight.infrastructure.entity.condition.CityInfoCondition;
import com.todo.sight.infrastructure.entity.condition.SightBaseCondition;
import com.todo.sight.infrastructure.entity.condition.SightPoiCondition;
import com.todo.sight.infrastructure.entity.domain.SightInfoDO;
import com.todo.sight.infrastructure.entity.po.CityInfoPO;
import com.todo.sight.infrastructure.entity.po.PoiTypeRelationPO;
import com.todo.sight.infrastructure.entity.po.SightBasePO;
import com.todo.sight.infrastructure.entity.po.SightPoiPO;
import com.todo.sight.infrastructure.helper.es.entity.SightDetailEntity;
import com.todo.sight.infrastructure.helper.es.entity.SightPoiEntity;
import com.todo.sight.service.api.response.SightDetailResponse;
import com.todo.sight.service.api.response.SightInfoResponse;
import org.apache.commons.collections4.CollectionUtils;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author azhebuxing
 * @date 2024/4/12 11:13
 * @description
 */
public class SightServiceConvert {

    public static CityInfoPO convertToCityInfoPO(CityInfoBO cityInfoBO) {
        if (cityInfoBO == null) {
            return null;
        }
        CityInfoPO cityInfoPO = new CityInfoPO();
        cityInfoPO.setId(cityInfoBO.getId() == null ? TodoCommonUtils.buildLongGuid() : cityInfoBO.getId());
        cityInfoPO.setName(cityInfoBO.getName());
        cityInfoPO.setParentId(cityInfoBO.getParentId());
        cityInfoPO.setType(cityInfoBO.getType() == null ? null : cityInfoBO.getType().getType());
        cityInfoPO.setOtherName(cityInfoBO.getOtherName());
        cityInfoPO.setMainImg(cityInfoBO.getMainImg());
        cityInfoPO.setDesc(cityInfoBO.getDesc());
        cityInfoPO.setIsShow(cityInfoBO.getIsShow());
        cityInfoPO.setLon(cityInfoBO.getLon());
        cityInfoPO.setLat(cityInfoBO.getLat());
        cityInfoPO.setIsDelete(0);
        cityInfoPO.setCreateTime(new Date());
        cityInfoPO.setUpdateTime(new Date());
        return cityInfoPO;
    }

    public static CityInfoBO convertToCityInfoBO(CityInfoPO cityInfoPO) {
        if (cityInfoPO == null) {
            return null;
        }
        CityInfoBO cityInfoBO = new CityInfoBO();
        cityInfoBO.setId(cityInfoPO.getId());
        cityInfoBO.setName(cityInfoPO.getName());
        cityInfoBO.setType(CityTypeEnum.getByType(cityInfoPO.getType()));
        cityInfoBO.setIsShow(cityInfoPO.getIsShow());
        cityInfoBO.setOtherName(cityInfoPO.getOtherName());
        cityInfoBO.setParentId(cityInfoPO.getParentId());
        cityInfoBO.setDesc(cityInfoPO.getDesc());
        cityInfoBO.setMainImg(cityInfoPO.getMainImg());
        cityInfoBO.setLon(cityInfoPO.getLon());
        cityInfoBO.setLat(cityInfoPO.getLat());
        return cityInfoBO;
    }

    public static List<CityInfoBO> convertToCityInfoBOList(List<CityInfoPO> cityInfoPOList) {
        if (CollectionUtils.isEmpty(cityInfoPOList)) {
            return Lists.newArrayList();
        }
        return cityInfoPOList.stream().map(SightServiceConvert::convertToCityInfoBO).collect(Collectors.toList());
    }

    public static SightPoiPO convertToSightPoiPO(SightPoiBO sightPoiBO) {
        if (sightPoiBO == null) {
            return null;
        }
        SightPoiPO sightPoiPO = new SightPoiPO();
        sightPoiPO.setId(sightPoiBO.getId() == null ? TodoCommonUtils.buildLongGuid() : sightPoiBO.getId());
        sightPoiPO.setName(sightPoiBO.getName());
        sightPoiPO.setTypeList(JSONObject.toJSONString(sightPoiBO.getTypeList()));
        sightPoiPO.setAddress(sightPoiBO.getAddress());
        sightPoiPO.setBusinessType(sightPoiBO.getBusinessType().getType());
        sightPoiPO.setOpenTime(sightPoiBO.getOpenTime());
        sightPoiPO.setDistrict(sightPoiBO.getDistrict());
        sightPoiPO.setPoiType(sightPoiBO.getPoiType());
        sightPoiPO.setProvince(sightPoiBO.getProvince());
        sightPoiPO.setTown(sightPoiBO.getTown());
        sightPoiPO.setCity(sightPoiBO.getCity());
        sightPoiPO.setLat(sightPoiBO.getLat());
        sightPoiPO.setLon(sightPoiBO.getLon());
        sightPoiPO.setRating(sightPoiBO.getRating());
        sightPoiPO.setIsShow(sightPoiBO.getIsShow() == null ? EnableTypeEnum.FORBIDDEN.getType() : sightPoiBO.getIsShow().getType());
        sightPoiPO.setIsDelete(0);
        sightPoiPO.setCreateTime(new Date());
        sightPoiPO.setUpdateTime(new Date());
        return sightPoiPO;
    }

    public static SightPoiBO convertToSightPoiBO(SightPoiPO sightPoiPO) {
        if (sightPoiPO == null) {
            return null;
        }
        SightPoiBO sightPoiBO = new SightPoiBO();
        sightPoiBO.setId(sightPoiPO.getId());
        sightPoiBO.setName(sightPoiPO.getName());
        sightPoiBO.setTypeList(JSONObject.parseArray(sightPoiPO.getTypeList(), String.class));
        sightPoiBO.setAddress(sightPoiPO.getAddress());
        sightPoiBO.setBusinessType(PoiBusinessTypeEnum.getByType(sightPoiPO.getBusinessType()));
        sightPoiBO.setOpenTime(sightPoiPO.getOpenTime());
        sightPoiBO.setDistrict(sightPoiPO.getDistrict());
        sightPoiBO.setPoiType(sightPoiPO.getPoiType());
        sightPoiBO.setTown(sightPoiPO.getTown());
        sightPoiBO.setProvince(sightPoiPO.getProvince());
        sightPoiBO.setCity(sightPoiPO.getCity());
        sightPoiBO.setLat(sightPoiPO.getLat());
        sightPoiBO.setLon(sightPoiPO.getLon());
        sightPoiBO.setRating(sightPoiPO.getRating());
        sightPoiBO.setIsShow(EnableTypeEnum.getByType(sightPoiPO.getIsShow()));
        return sightPoiBO;
    }

    public static List<SightPoiBO> convertToSightPoiBOList(List<SightPoiPO> sightPoiPOList) {
        if (CollectionUtils.isEmpty(sightPoiPOList)) {
            return Lists.newArrayList();
        }
        return sightPoiPOList.stream().map(SightServiceConvert::convertToSightPoiBO).collect(Collectors.toList());
    }

    public static SightPoiCondition convertToSightPoiCondition(PoiConditionBO poiConditionBO) {
        if (poiConditionBO == null) {
            return null;
        }
        SightPoiCondition sightPoiCondition = new SightPoiCondition();
        sightPoiCondition.setCity(poiConditionBO.getCity());
        sightPoiCondition.setPageIndex(poiConditionBO.getPageIndex());
        sightPoiCondition.setPageSize(poiConditionBO.getPageSize());
        sightPoiCondition.setPoiType(poiConditionBO.getPoiType() == null ? null : poiConditionBO.getPoiType().getType());
        sightPoiCondition.setProvince(poiConditionBO.getProvince());
        sightPoiCondition.setName(poiConditionBO.getName());
        sightPoiCondition.setBusinessType(poiConditionBO.getBusinessType());
        sightPoiCondition.setCurrentIndex(poiConditionBO.getCurrentIndex());
        return sightPoiCondition;
    }

    public static SightInfoDO convertToSightInfoDO(SightDetailBO sightDetailBO) {
        if (sightDetailBO == null) {
            return null;
        }
        SightInfoDO sightInfoDO = new SightInfoDO();
        sightInfoDO.setId(sightDetailBO.getId() == null ? TodoCommonUtils.buildLongGuid() : sightDetailBO.getId());
        SightInfoDO.SightBase sightBase = new SightInfoDO.SightBase();
        sightBase.setAddress(sightDetailBO.getAddress());
        sightBase.setCity(sightDetailBO.getCity());
        sightBase.setExtra(JSONObject.toJSONString(sightDetailBO.getExtra()));
        sightBase.setHot(sightDetailBO.getHot());
        sightBase.setIsOpen(sightDetailBO.getIsOpen().getType());
        sightBase.setIsShow(sightDetailBO.getIsShow());
        sightBase.setMainImg(sightDetailBO.getMainImg());
        sightBase.setProvince(sightDetailBO.getProvince());
        sightBase.setScore(sightDetailBO.getScore());
        sightBase.setSource(sightDetailBO.getSource().getType());
        sightBase.setSlogan(sightDetailBO.getSlogan());
        sightBase.setTitle(sightDetailBO.getTitle());
        sightBase.setPoiId(sightDetailBO.getPoiId());
        sightInfoDO.setSightBase(sightBase);

        SightInfoDO.SightDetail sightDetail = new SightInfoDO.SightDetail();
        sightDetail.setDesc(sightDetailBO.getDesc());
        sightDetail.setTicketInfo(JSONObject.toJSONString(sightDetailBO.getTicketInfo()));
        sightDetail.setOpenTime(sightDetailBO.getOpenTime());
        sightDetail.setSuggest(JSONObject.toJSONString(sightDetailBO.getSuggest()));
        sightInfoDO.setSightDetail(sightDetail);
        sightInfoDO.setCreateUser(sightDetailBO.getCreateUser());
        sightInfoDO.setLastUpdateUser(sightDetailBO.getLastUpdateUser());
        return sightInfoDO;
    }

    public static SightDetailBO convertToSightDetailBO(SightInfoDO sightInfoDO) {
        if (sightInfoDO == null || sightInfoDO.getSightBase() == null || sightInfoDO.getSightDetail() == null) {
            return null;
        }
        SightInfoDO.SightBase sightBase = sightInfoDO.getSightBase();
        SightInfoDO.SightDetail sightDetail = sightInfoDO.getSightDetail();
        SightDetailBO sightDetailBO = new SightDetailBO();
        sightDetailBO.setId(sightInfoDO.getId());
        sightDetailBO.setAddress(sightBase.getAddress());
        sightDetailBO.setCity(sightBase.getCity());
        sightDetailBO.setExtra(JSONObject.parseObject(sightBase.getExtra(), SightDetailBO.Extra.class));
        sightDetailBO.setHot(sightBase.getHot());
        sightDetailBO.setIsOpen(EnableTypeEnum.getByType(sightBase.getIsOpen()));
        sightDetailBO.setIsShow(sightBase.getIsShow());
        sightDetailBO.setMainImg(sightBase.getMainImg());
        sightDetailBO.setProvince(sightBase.getProvince());
        sightDetailBO.setScore(sightBase.getScore());
        sightDetailBO.setSource(SourceEnum.getByType(sightBase.getSource()));
        sightDetailBO.setSlogan(sightBase.getSlogan());
        sightDetailBO.setTitle(sightBase.getTitle());
        sightDetailBO.setPoiId(sightBase.getPoiId());
        sightDetailBO.setDesc(sightDetail.getDesc());
        sightDetailBO.setTicketInfo(JSONObject.parseObject(sightDetail.getTicketInfo(), SightDetailBO.TicketInfo.class));
        sightDetailBO.setOpenTime(sightDetail.getOpenTime());
        sightDetailBO.setSuggest(JSONObject.parseObject(sightDetail.getSuggest(), SightDetailBO.Suggest.class));

        return sightDetailBO;
    }


    public static SightBaseBO convertToSightBaseBO(SightDetailBO sightDetailBO) {
        if (sightDetailBO == null) {
            return null;
        }
        SightBaseBO sightBaseBO = new SightBaseBO();
        sightBaseBO.setId(sightDetailBO.getId());
        sightBaseBO.setSlogan(sightDetailBO.getSlogan());
        sightBaseBO.setCity(sightDetailBO.getCity());
        sightBaseBO.setExtra(JSONObject.parseObject(JSONObject.toJSONString(sightDetailBO.getExtra()), SightBaseBO.Extra.class));
        sightBaseBO.setHot(sightDetailBO.getHot());
        sightBaseBO.setIsOpen(sightDetailBO.getIsOpen());
        sightBaseBO.setIsShow(sightDetailBO.getIsShow());
        sightBaseBO.setMainImg(sightDetailBO.getMainImg());
        sightBaseBO.setProvince(sightDetailBO.getProvince());
        sightBaseBO.setScore(sightDetailBO.getScore());
        sightBaseBO.setSource(sightDetailBO.getSource());
        sightBaseBO.setTitle(sightDetailBO.getTitle());
        sightBaseBO.setPoiId(sightDetailBO.getPoiId());
        sightBaseBO.setAddress(sightDetailBO.getAddress());
        return sightBaseBO;
    }

    public static SightBaseBO convertToSightBaseBO(SightBasePO sightBasePO) {
        if (sightBasePO == null) {
            return null;
        }
        SightBaseBO sightBaseBO = new SightBaseBO();
        sightBaseBO.setId(sightBasePO.getId());
        sightBaseBO.setSlogan(sightBasePO.getSlogan());
        sightBaseBO.setCity(sightBasePO.getCity());
        sightBaseBO.setExtra(JSONObject.parseObject(sightBasePO.getExtra(), SightBaseBO.Extra.class));
        sightBaseBO.setHot(sightBasePO.getHot());
        sightBaseBO.setIsOpen(EnableTypeEnum.getByType(sightBasePO.getIsOpen()));
        sightBaseBO.setIsShow(sightBasePO.getIsShow());
        sightBaseBO.setMainImg(sightBasePO.getMainImg());
        sightBaseBO.setProvince(sightBasePO.getProvince());
        sightBaseBO.setScore(sightBasePO.getScore());
        sightBaseBO.setSource(SourceEnum.getByType(sightBasePO.getSource()));
        sightBaseBO.setTitle(sightBasePO.getTitle());
        sightBaseBO.setPoiId(sightBasePO.getPoiId());
        sightBaseBO.setAddress(sightBasePO.getAddress());

        return sightBaseBO;
    }

    public static SightBaseCondition convertToSightBaseCondition(SightQueryConditionBO sightQueryConditionBO) {
        if (sightQueryConditionBO == null) {
            return null;
        }
        SightBaseCondition sightBaseCondition = new SightBaseCondition();
        sightBaseCondition.setSource(sightQueryConditionBO.getSource() == null ? null : sightQueryConditionBO.getSource().getType());
        sightBaseCondition.setPageIndex(sightQueryConditionBO.getPageIndex());
        sightBaseCondition.setPageSize(sightQueryConditionBO.getPageSize());
        sightBaseCondition.setCurrentIndex(sightQueryConditionBO.getCurrentIndex());
        sightBaseCondition.setId(sightQueryConditionBO.getId());
        sightBaseCondition.setCity(sightQueryConditionBO.getCity());
        sightBaseCondition.setTitle(sightQueryConditionBO.getTitle());
        sightBaseCondition.setPoiId(sightQueryConditionBO.getPoiId());
        sightBaseCondition.setProvince(sightQueryConditionBO.getProvince());
        return sightBaseCondition;
    }

    public static List<SightBaseBO> convertToSightBaseBOList(List<SightBasePO> sightBasePOList) {
        if (CollectionUtils.isEmpty(sightBasePOList)) {
            return Lists.newArrayList();
        }
        return sightBasePOList.stream().map(SightServiceConvert::convertToSightBaseBO).collect(Collectors.toList());
    }

    public static PoiTypeRelationPO convertToPoiTypeRelationPO(PoiTypeRelationBO poiTypeRelationBO) {
        if (poiTypeRelationBO == null) {
            return null;
        }
        PoiTypeRelationPO poiTypeRelationPO = new PoiTypeRelationPO();
        poiTypeRelationPO.setBizType(poiTypeRelationBO.getBizType().getType());
        poiTypeRelationPO.setPoiId(poiTypeRelationBO.getPoiId());
        poiTypeRelationPO.setId(poiTypeRelationBO.getId());
        poiTypeRelationPO.setBusinessId(poiTypeRelationBO.getBusinessId());
        poiTypeRelationPO.setPoiType(poiTypeRelationBO.getPoiType());
        return poiTypeRelationPO;
    }

    public static List<PoiTypeRelationBO> convertToPoiTypeRelationPOList(List<PoiTypeRelationPO> poiTypeRelationPOS) {
        if (CollectionUtils.isEmpty(poiTypeRelationPOS)) {
            return Lists.newArrayList();
        }
        return poiTypeRelationPOS.stream().map(SightServiceConvert::convertToPoiTypeRelationBO).collect(Collectors.toList());
    }

    private static PoiTypeRelationBO convertToPoiTypeRelationBO(PoiTypeRelationPO poiTypeRelationPO) {
        if (poiTypeRelationPO == null) {
            return null;
        }
        PoiTypeRelationBO poiTypeRelationBO = new PoiTypeRelationBO();
        poiTypeRelationBO.setBizType(PoiBusinessTypeEnum.getByType(poiTypeRelationPO.getBizType()));
        poiTypeRelationBO.setPoiId(poiTypeRelationPO.getPoiId());
        poiTypeRelationBO.setId(poiTypeRelationPO.getId());
        poiTypeRelationBO.setBusinessId(poiTypeRelationPO.getBusinessId());
        poiTypeRelationBO.setPoiType(poiTypeRelationPO.getPoiType());
        return poiTypeRelationBO;
    }

    public static CityInfoCondition convertToCityInfoCondition(CityInfoConditionBO conditionBO) {
        if (conditionBO == null) {
            return null;
        }
        CityInfoCondition cityInfoCondition = new CityInfoCondition();
        cityInfoCondition.setPageIndex(conditionBO.getPageIndex());
        cityInfoCondition.setPageSize(conditionBO.getPageSize());
        cityInfoCondition.setCurrentIndex(conditionBO.getCurrentIndex());
        cityInfoCondition.setCityId(conditionBO.getCityId());
        cityInfoCondition.setName(conditionBO.getName());
        cityInfoCondition.setType(conditionBO.getType() == null ? null : conditionBO.getType().getType());
        cityInfoCondition.setIsShow(conditionBO.getIsShow());
        return cityInfoCondition;
    }

    public static SightPoiEntity convertToSightPoiEntity(SightPoiBO sightPoiBO) {
        if (sightPoiBO == null) {
            return null;
        }
        SightPoiEntity sightPoiEntity = new SightPoiEntity();
        sightPoiEntity.setBusinessType(sightPoiBO.getBusinessType().getType());
        sightPoiEntity.setCity(sightPoiBO.getCity());
        sightPoiEntity.setDistrict(sightPoiBO.getDistrict());
        sightPoiEntity.setLon(String.valueOf(sightPoiBO.getLon()));
        sightPoiEntity.setLat(String.valueOf(sightPoiBO.getLat()));
        sightPoiEntity.setId(sightPoiBO.getId().toString());
        sightPoiEntity.setIsShow(sightPoiBO.getIsShow() == null ? EnableTypeEnum.FORBIDDEN.getType() : sightPoiBO.getIsShow().getType());
        sightPoiEntity.setMysqlId(sightPoiBO.getId());
        sightPoiEntity.setPoiType(sightPoiBO.getPoiType());
        sightPoiEntity.setProvince(sightPoiBO.getProvince());
        sightPoiEntity.setTown(sightPoiBO.getTown());
        sightPoiEntity.setName(sightPoiBO.getName());
        sightPoiEntity.setAddress(sightPoiBO.getAddress());
        return sightPoiEntity;
    }

    public static SightDetailEntity convertToSightDetailEntity(SightInfoDO sightInfoDO) {
        if (sightInfoDO == null || sightInfoDO.getSightBase() == null) {
            return null;
        }
        SightInfoDO.SightBase sightBase = sightInfoDO.getSightBase();
        SightDetailEntity sightDetailEntity = new SightDetailEntity();
        sightDetailEntity.setMysqlId(sightInfoDO.getId());
        sightDetailEntity.setCity(sightBase.getCity());
        sightDetailEntity.setHot(sightBase.getHot());
        sightDetailEntity.setIsOpen(sightBase.getIsOpen());
        sightDetailEntity.setIsShow(sightBase.getIsShow());
        sightDetailEntity.setMainImg(sightBase.getMainImg());
        sightDetailEntity.setOpenTime(sightInfoDO.getSightDetail().getOpenTime());
        sightDetailEntity.setScore(sightBase.getScore());
        sightDetailEntity.setSlogan(sightBase.getSlogan());
        sightDetailEntity.setTitle(sightBase.getTitle());
        sightDetailEntity.setProvince(sightBase.getProvince());
        sightDetailEntity.setAddress(sightBase.getAddress());
        sightDetailEntity.setDesc(sightInfoDO.getSightDetail().getDesc());
        sightDetailEntity.setPoiId(sightInfoDO.getSightBase().getPoiId());
        return sightDetailEntity;
    }

    public static SightDetailResponse convertToSightDetailResponse(SightDetailBO sightDetailBO) {
        if (sightDetailBO == null) {
            return null;
        }
        SightDetailResponse response = new SightDetailResponse();
        response.setId(sightDetailBO.getId());
        response.setTitle(sightDetailBO.getTitle());
        response.setSlogan(sightDetailBO.getSlogan());
        response.setPoiId(sightDetailBO.getPoiId());
        response.setProvince(sightDetailBO.getProvince());
        response.setCity(sightDetailBO.getCity());
        response.setScore(sightDetailBO.getScore());
        response.setHot(sightDetailBO.getHot());
        response.setAddress(sightDetailBO.getAddress());
        response.setMainImg(sightDetailBO.getMainImg());
        response.setSource(sightDetailBO.getSource());
        response.setIsShow(sightDetailBO.getIsShow());
        response.setIsOpen(sightDetailBO.getIsOpen());
        response.setDesc(sightDetailBO.getDesc());
        if (sightDetailBO.getTicketInfo() != null) {
            SightDetailResponse.TicketInfo ticketInfo = new SightDetailResponse.TicketInfo();
            ticketInfo.setTicketDiscountInfo(sightDetailBO.getTicketInfo().getTicketDiscountInfo());
            ticketInfo.setTicketPrice(sightDetailBO.getTicketInfo().getTicketPrice());
            ticketInfo.setTicketRule(sightDetailBO.getTicketInfo().getTicketRule());
            response.setTicketInfo(ticketInfo);
        }
        response.setOpenTime(sightDetailBO.getOpenTime());
        if (sightDetailBO.getSuggest() != null) {
            SightDetailResponse.Suggest suggest = new SightDetailResponse.Suggest();
            suggest.setSuggestInfo(sightDetailBO.getSuggest().getSuggestInfo());
            suggest.setSecuritySuggest(sightDetailBO.getSuggest().getSecuritySuggest());
            suggest.setTravelLimit(sightDetailBO.getSuggest().getTravelLimit());
            suggest.setGuide(sightDetailBO.getSuggest().getGuide());
            suggest.setSuggestInfo(sightDetailBO.getSuggest().getSuggestInfo());
            response.setSuggest(suggest);
        }
        if (sightDetailBO.getExtra() != null) {
            response.setImgList(sightDetailBO.getExtra().getImgList());
        }
        return response;
    }

    public static SightInfoResponse convertToSightInfoResponse(SightBaseBO sightBaseBO) {
        if (sightBaseBO == null){
            return null;
        }
        SightInfoResponse response = new SightInfoResponse();
        response.setSightId(sightBaseBO.getId());
        response.setTitle(sightBaseBO.getTitle());
        response.setSlogan(sightBaseBO.getSlogan());
        response.setPoiId(sightBaseBO.getPoiId());
        response.setProvince(sightBaseBO.getProvince());
        response.setCity(sightBaseBO.getCity());
        response.setScore(sightBaseBO.getScore());
        response.setHot(sightBaseBO.getHot());
        response.setAddress(sightBaseBO.getAddress());
        response.setMainImg(sightBaseBO.getMainImg());
        response.setSource(sightBaseBO.getSource());
        response.setIsShow(sightBaseBO.getIsShow());
        response.setIsOpen(sightBaseBO.getIsOpen());
        return response;
    }

    public static SearchSightPoiDetailBO convertToSearchSightDetailBO(SightPoiEntity entity) {
        if (entity == null){
            return null;
        }
        SearchSightPoiDetailBO detailBO = new SearchSightPoiDetailBO();
        detailBO.setPoiId(entity.getMysqlId());
        detailBO.setCity(entity.getCity());
        detailBO.setAddress(entity.getAddress());
        detailBO.setPoiType(entity.getPoiType());
        detailBO.setLon(entity.getLon());
        detailBO.setLat(entity.getLat());
        detailBO.setName(entity.getName());
        detailBO.setProvince(entity.getProvince());
        detailBO.setTown(entity.getTown());
        detailBO.setIsShow(EnableTypeEnum.getByType(entity.getIsShow()));
        detailBO.setBusinessType(BusinessSceneEnum.getBusinessSceneEnumByScene(entity.getBusinessType()));
        detailBO.setDistrict(entity.getDistrict());
        return detailBO;
    }

    public static SearchSightSummaryDetailBO buildSearchSightSummaryDetailBO(SightDetailEntity entity, SightPoiBO sightPoiBO) {
        if (entity == null || sightPoiBO == null){
            return null;
        }
        SearchSightSummaryDetailBO detailBO = new SearchSightSummaryDetailBO();
        detailBO.setSightId(entity.getMysqlId());
        detailBO.setSightId(sightPoiBO.getId());

        SearchSightSummaryDetailBO.SightSummary sightSummary = new SearchSightSummaryDetailBO.SightSummary();
        sightSummary.setHot(entity.getHot());
        sightSummary.setSlogan(entity.getSlogan());
        sightSummary.setOpenTime(entity.getOpenTime());
        sightSummary.setScore(entity.getScore());
        sightSummary.setDesc(entity.getDesc());
        sightSummary.setTitle(entity.getTitle());
        sightSummary.setMainImg(entity.getMainImg());
        sightSummary.setAddress(entity.getAddress());
        sightSummary.setCity(entity.getCity());
        sightSummary.setProvince(entity.getProvince());
        sightSummary.setIsShow(EnableTypeEnum.getByType(entity.getIsShow()));
        sightSummary.setIsOpen(entity.getIsOpen());
        detailBO.setSightSummary(sightSummary);

        SearchSightSummaryDetailBO.SightPoi sightPoi = new SearchSightSummaryDetailBO.SightPoi();
        sightPoi.setName(sightPoiBO.getName());
        sightPoi.setTypeList(sightPoiBO.getTypeList());
        sightPoi.setDistrict(sightPoiBO.getDistrict());
        sightPoi.setTown(sightPoiBO.getTown());
        sightPoi.setProvince(sightPoiBO.getProvince());
        sightPoi.setCity(sightPoiBO.getCity());
        sightPoi.setRating(sightPoiBO.getRating());
        sightPoi.setOpenTime(sightPoiBO.getOpenTime());
        sightPoi.setPoiType(sightPoiBO.getPoiType());
        sightPoi.setBusinessType(sightPoiBO.getBusinessType());
        sightPoi.setLon(sightPoiBO.getLon());
        sightPoi.setAddress(sightPoiBO.getAddress());
        sightPoi.setLat(sightPoiBO.getLat());
        detailBO.setPoiInfo(sightPoi);

        return detailBO;
    }
}
